const { GoodsModel } = require('../db/model')


const getGoodsList = async (req, res, next) => {
  let { current } = req.params
  if (!current) current = 1
  const data = await GoodsModel.find().skip((current - 1) * 12).limit(12)
  const cates = await GoodsModel.distinct('cate')
  req.pagi = {
    current,
    data,
    cates,
  }
  next()
}

module.exports = {
  getGoodsList
}